import { get, post } from '@/utils/request'

enum Api {
  CategoryList = '/aiCreate/noAuth/getCategoryList',
  CategoryDetail = '/aiCreate/noAuth/getCategoryInfo',
  sendAiCreate = '/chat_message/sendAiCreate',
  AiHistory = '/aiCreate/getAiCreateRecordList',
  delHistory = '/aiCreate/delAiCreateRecord',
  CategoryListByKeys = '/aiCreate/noAuth/getCategoryListByKeys',
  hotHistory = '/aiCreate/noAuth/getCategoryHotList'

}
/**
 * 
 * @returns 获取首页分类列表
 */
export function getIndexCategoryList() {
  return get({
    url: '/aiCreate/noAuth/getIndexCategoryList',
  })
}

/**
 * 获取分类 类型 列表
 */
export function getCateGoryListType() {
  return get({
    url: `/aiCreate/noAuth/getCategoryListType`
  })
} /aiCreate/
export function getCategoryListByTypeGroup() {
  return get({
    url: '/aiCreate/noAuth/getCategoryListByTypeGroup'
  })
}

/**
 * 获取首页所有分类
 */
export function getCategoryList(typeId: string) {
  return get({
    url: `/aiCreate/noAuth/getCategoryList?typeId=${typeId}`
  })
}

// 问题列表
export function QsList(data) {
  return post({
    url: '/faqs/qslist',
    data: data
  })
}
/**
 * 获取ai创作对应详情
 */
export function getCategoryDetail(id: string) {
  return get({
    url: Api.CategoryDetail + '?id=' + id,
  })
}

/**
 * 获取ai创作对应详情
 */
export function getsendAiCreate(data, onDownloadProgress) {
  return post({
    url: Api.sendAiCreate,
    data: data,
  })
}


// export function fetchChatAPIProcess<T = any>(
//    params: {
//      prompt: string
//      options?: { conversationId?: string; parentMessageId?: string }
//      signal?: GenericAbortSignal
//      onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void },
//  ) {
//    const data: Record<string, any> = {
//      prompt: params.prompt,
//      options: params.options,
//    }

//    return post<T>({
//      url: '/chat_message/send',
//      data,
//      signal: params.signal,
//      onDownloadProgress: params.onDownloadProgress,
//    })
//  }

export function fetchChatAPIProcess(data, onDownloadProgress) {
  return post({
    url: Api.sendAiCreate,
    data: data,
    onDownloadProgress: onDownloadProgress,
  })
}



/**
 * 获取ai创作历史记录
 */
export function GgetAiHistory(page) {
  return get({
    url: `/aiCreate/getAiCreateRecordList?page=${page}`,
  })
}

/**
 * 根据id删除ai创作历史记录
 */
export function delHistory(records) {
  const recordIds = records.join('&recordIds=');
  const url = Api.delHistory + '?recordIds=' + recordIds;

  return get({
    url: url,
  });
}


/**
 * 查询分类列表
 */
export function getCategoryListByKeys(data) {
  return get({
    url: Api.CategoryListByKeys,
    //   headers: {
    //     'Content-Type': 'multipart/form-data',
    //   },
    data: data
  });
}
export const getSiteInfo = () => {
  return get({
    url: '/site/getSiteInfo'
  })
}

export function GethotHistory(data) {
  return get({
    url: Api.hotHistory,
    data: data
  })
}

// 获取账号起名的--homedetailInput 单选按钮等
export const getDetailType_Account = (id) => {
  return get({
    url: `/aiCreate/noAuth/getCategoryInfo?id=${id}`,
  })
}

// 详情页面的类别--homedetailInput 单选按钮等
export const getDetailType = (title: any) => {
  return get({
    url: `/faqs/qsTypeAttr?typeName=${title}`,
  })
}



// 获取首页banner
export function getSiteIndexBanner() {
  return get({
    url: `/site/getSiteIndexBanner`,
  })
}


// 获取首页banner跳转链接
export function getBannerInfo(id) {
  return get({
    url: `/banner/getBannerInfo?bannerId=${id}`,
  })
}

